package com.hmdp.config;

import lombok.extern.slf4j.Slf4j;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author：Fu ChenYu
 * @Date：2024/11/27 10:19
 * @Description：RedissonConfig
 */
@Configuration
@Slf4j
public class RedissonConfig {

    @Value("${spring.redis.address}")
    private String address;
    @Value("${spring.redis.password}")
    private String password;

    @Bean
    RedissonClient redissonClient(){
        //1.创建配置
        Config config = new Config();
        config.useSingleServer().setAddress(address).setPassword(null);
        log.info("password:{}",password);
        //2.根据config创建RedissonClient实例
        return Redisson.create(config);
    }
}
